// © 2009 Microsoft Corporation.  All rights reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Microsoft.InformationSecurity.ISRM.TaskManagment.NotificationsService
{
    /// <summary>
    /// Static helper class to read service configuration values.
    /// </summary>
    internal static class ServiceConfiguration
    {

        /// <summary>
        /// Time of day when the notifications are built and sent.
        /// </summary>
        public static TimeSpan NotificationsBuildTime
        {
            get { return TimeSpan.Parse(ConfigurationManager.AppSettings["notificationsBuildTime"]); }  
        }

        /// <summary>
        /// Number of simlutaneous messages to be sent.
        /// </summary>
        public static int SimultaneousMessageCount 
        {
            get { return int.Parse(ConfigurationManager.AppSettings["simultaneousMessageCount"]); }
        }

        /// <summary>
        /// Manually check new notifications for the specified number of minutes. 
        /// </summary>
        public static int ManualNotificationsCheckMinutes 
        {
            get { return int.Parse(ConfigurationManager.AppSettings["manualDBNotificationCheck"]); }
        }

        /// <summary>
        /// Name of the service in windows service manager
        /// </summary>
        public static string ServiceName 
        {
            get { return ConfigurationManager.AppSettings["serviceName"]; }
        }

        /// <summary>
        /// Path to the dynamic text task summary table xslt file
        /// </summary>
        public static string TasksSummaryTableXsl
        {
            get { return ConfigurationManager.AppSettings["$TasksSummaryTable$XSL"]; }
        }

        /// <summary>
        /// Path to the dynamic text task summary table xslt file
        /// </summary>
        public static string TaskOwnerXsl
        {
            get { return ConfigurationManager.AppSettings["$TaskOwner$XSL"]; }
        }

        /// <summary>
        /// Path to the file containing header and footer of the mail notification
        /// </summary>
        public static string MailTemplate
        {
            get { return ConfigurationManager.AppSettings["mailTemplate"]; }
        }

        /// <summary>
        /// Base directory of the service assembly.
        /// </summary>
        public static string ServiceExecutableDirectory 
        {
            get { return AppDomain.CurrentDomain.BaseDirectory; }
        }

        /// <summary>
        /// Class Type used by the engine to send notifications
        /// </summary>
        public static Type NotificationType 
        {
            get { return Type.GetType(ConfigurationManager.AppSettings["notificationType"]); }
        }

        /// <summary>
        /// Regular Expression for email address
        /// </summary>
        public static string EmailRegularExpression
        {
            get { return ConfigurationManager.AppSettings["emailRegex"];  }
        }

        /// <summary>
        /// SMTP Server Address
        /// </summary>
        public static string SmtpServer
        {
            get { return ConfigurationManager.AppSettings["smtpServer"]; }
        }

        /// <summary>
        /// From email address to send emails from.
        /// </summary>
        public static string FromEmailAddress
        {
            get { return ConfigurationManager.AppSettings["fromEmailAddress"]; }
        }
    }
}
